# 公共条用方法
import configDB as Mysql_Db
import filelog

#v5_sqlMapper = Mysql_Db.Mysql('DATABASE_1')


# 行数据插入信息记录
def insert_conversion(newId, oldId, newTable, oldTable, newDatabases, oldDatabase,new_webId,old_webId):
    # 插入记录sql信息
    sqls = "insert into data_conversion_info(new_id,old_id,new_table,old_table,new_database,old_database,new_webId,old_webId,datetime)VALUES(" + str(newId) + "," + str(oldId) + "," + "'" + newTable + "','" + oldTable + "','" + newDatabases + "','" + oldDatabase+"',"+str(new_webId)+","+str(old_webId)+ ",sysdate());"
    # 执行插入数据记录信息
    filelog.logInfo('v4-v5行数据插入信息记录-data_conversion_info.....V4站点:' + str(old_webId) + 'V5站点:' + str(new_webId), 'debug')
    return sqls


# 数据表插入记录
def insert_tables(newTable, oldTable, newDatabases, oldDatabase, recordCount,new_webId,old_webId):
    # 记录表操作信息sql
    sqls = "insert into data_tables_info(new_table,old_table,new_database,old_database,new_webId,old_webId,extract_count,now_status,datetime) " \
         +"VALUES('" + newTable + "','" + oldTable + "','" + newDatabases + "','" + oldDatabase + "',"+str(new_webId)+","+str(old_webId)+","+str(recordCount) + ",1,sysdate());"
    filelog.logInfo('v4-v5转换数据站点总数插入信息记录-data_tables_info.....V4站点:' + str(old_webId) + 'V5站点:' + str(new_webId), 'debug')
    return sqls

# 字符转换方法，将参数加上标点单点符合
def str_symbol(str):
    if str != None:
        return "'" + str + "'"
    else:
        return str

def str_symbols(str):
    if str != None:
        return '"' + str + '"'
    else:
        return str

# 字符转换方法，将参数加上标点单点符合
def time_symbol(str):
    if str != None:
        return "'" + str(str) + "'"
    else:
        return str


